﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;


namespace GonguklubburinnMVC.Models
{
    public class MountainRepository
    {

       // MountainDBDataContext m_db = new MountainDBDataContext();
        MountainsDBEntities1 db = new MountainsDBEntities1();

        public IEnumerable<MountainE> showAll()
        {
            return db.Mountains;
        }

		public IEnumerable<MountainE> ShowAllWithNO()
		{
			var mntain = showAll();
			mntain = from m in db.Mountains
					 where m.InsertDate > DateTime.Now 
					 orderby m.InsertDate ascending
					 select m;
					
						

			return mntain;
			
		}
		public IEnumerable<MountainE> ShowAllWithYes()
		{
			var mntain = showAll();
			mntain = from m in db.Mountains
					 where m.InsertDate < DateTime.Now
					 select m;



			return mntain;
			
		}

				
        public void AddMountain(MountainE m)
        {       
            db.Mountains.AddObject(m);
        }

      

        public MountainE GetMountain(int id)
        {

           return db.Mountains.SingleOrDefault(m => m.ID == id);
        }

        public void Delete(MountainE mountain)
        {
            db.Mountains.DeleteObject(mountain);
        }

        public void save()
        {
            db.SaveChanges();

        }

    }
}